import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const VueRouterPush = VueRouter.prototype.push

VueRouter.prototype.push = function push (to) {

      return VueRouterPush.call(this, to).catch(err => err)

}

const routes = [
  {
    path: '/',
    name: 'home',
    component:  HomeView,
    children:[
      {
        path:'recommend',
        name:'recommend',
        component:()=>import('@/views/RecommendView.vue')
      },
      {
        path:'note',
        name:'note',
        component:()=>import('@/views/NoteView')
      },
      {
        path:'video',
        name:'video',
        component:()=>import('@/views/VideoView')
      },
      {
        path:'follow',
        name:'follow',
        component:()=>import('@/views/FollowView')
      },
      {
        path:'activity',
        name:'activity',
        component:()=>import('@/views/ActivityView')
      },
    ]
  },
  {
    path:'/search',
    name:'search',
    component:()=>import('@/views/Search.vue'),
    children:[
      {
        path:'hotsearch',
        name:'hotsearch',
        component:()=>import('@/views/Hotsearch.vue'),
      },
      {
        path:'searchCont',
        name:'searchCont',
        component:()=>import('@/views/SearchCont.vue'),
      }
    ]
  },
  {
    path:'/type1',
    name:'type1',
    component:()=>import('@/views/Type1.vue')
  },
  {
    path:'/type3',
    name:'type3',
    component:()=>import('@/views/Type3.vue')
  },
  {
    path:'/activityCont',
    name:'activityCont',
    component:()=>import('@/views/ActivityCont.vue')
  },
  {
    path:'/user',
    name:'user',
    component:()=>import('@/views/User.vue'),
    children:[
      {
        path:'caipu',
        name:'caipu',
        component:()=>import('@/views/Caipu.vue')
      },
      {
        path:'biji',
        name:'biji',
        component:()=>import('@/views/Biji.vue')
      },
      {
        path:'shoucang',
        name:'shoucang',
        component:()=>import('@/views/shoucang.vue')
      },
    ]
  },
  {
    path:'/fenlei',
    name:'fenlei',
    component:()=>import('@/views/Fenlei.vue')
  },
  {
    path:'/login',
    name:'login',
    component:()=>import('@/views/Login.vue')
  },
]

const router = new VueRouter({
  routes,
  mode: 'hash'
})

export default router
